package com.atguigu.day08;

import com.atguigu.utils.ClickSource;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Example3 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env =
                StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        // flink默认只保存最近一次检查点
        // 设置每隔10秒钟保存一次检查点
        env.enableCheckpointing(10 * 1000L);
        // 保存检查点的文件夹的路径
        env.setStateBackend(
                new FsStateBackend("file:///home/zuoyuan/flink0609/src/main/resources/ckpts", false)
        );

        env
                .addSource(new ClickSource())
                .print();

        env.execute();
    }
}
